<template>
    <div>
      <el-table
        :data="circleList"
        style="width: 100%"
        :show-header=false>
        <el-table-column
          width="600px">
          <template slot-scope="scope">
            <el-form  :model="scope.row" style="width: 600px;height:600px">
              <el-form-item style="width: 400px">
                  <el-image :src="scope.row.images" style="width: 60px;height: 40px"></el-image>
                  <span>{{scope.row.name}}</span>
                  <el-button style="color: red" @click="sendMessage(scope.row.userId,scope.row.roleId,scope.row.images)">立刻资讯</el-button>
                  <el-button style="color: red" @click="callPhone(scope.row.phone)">拨打电话</el-button>
              </el-form-item>
              <el-form-item>
                {{scope.row.content}}
              </el-form-item>
              <el-form-item>
                {{scope.row.createTime}}
              </el-form-item>
              <el-form-item>
                <el-image :src="scope.row.imagesJson" style="width: 300px;height: 200px"></el-image>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
      </el-table>
    </div>
</template>
<script>
import { findCircle, findMessageRecordByOne } from '@/api/consumer/consumer'
export default {
  name: 'Index',
  data() {
    return {
      // 楼市圈
      circleList: [],
      // 用户对象
      messageList: [],
      // 消息传输对象
      messageResult: {
        toUserId: null,
        toUserRole: null,
        images: null
      }
    }
  },
  created() {
    this.findList()
  },
  methods: {
    findList() {
      findCircle().then(res => {
        this.circleList = res.data
      })
    },
    callPhone() {},
    // 咨询
    sendMessage(userId, roleId, images) {
      this.messageResult.toUserId = userId
      this.messageResult.toUserRole = roleId
      this.messageResult.images = images
      console.log(this.messageResult)
      findMessageRecordByOne(this.messageResult).then(res => {
        this.messageList = res.data
        this.$router.push({
          path: '/message/index',
          query: {
            messageRecordList: this.messageList,
            toUserId: this.messageResult.toUserId,
            toRoleId: this.messageResult.toUserRole,
            images: this.messageResult.images
          }
        })
      })
    }
  }
}
</script>
<style scoped>
</style>
